implementation math *800

Please click on ads to support us..

Python Code:

L,R,A = map(int,input().split())
print(2*min(L+A,R+A,(A+L+R)// 2))

C++ Code:

#include<bits/stdc++.h>
using namespace std;
int main()
{
    int t=1;
    // cin>>t;
    while(t--){
        int l,r,b,ans,x;
        cin>>l>>r>>b;

        if(l<r){
            if((l+b)<r){
                ans=2*(l+b);
            }
            else{
                x=((l+b)-r)/2;
                ans=(2*r)+2*x;
            }
        }

        else{
            if((r+b)<l){
                ans=2*(r+b);
            }
            else{
                x=((r+b)-l)/2;
                ans=(2*l)+2*x;
            }
        }

        cout<<ans;
        cout<<endl;
    }
}


Comments

Submit
0 Comments
More Questions

32. Longest Valid Parentheses
Cutting a material
Bubble Sort
Number of triangles
AND path in a binary tree
Factorial equations
Removal of vertices
Happy segments
Cyclic shifts
Zoos
Build a graph
Almost correct bracket sequence
Count of integers
Differences of the permutations
Doctor's Secret
Back to School
I am Easy
Teddy and Tweety
Partitioning binary strings
Special sets
Smallest chosen word
Going to office
Color the boxes
Missing numbers
Maximum sum
13 Reasons Why
Friend's Relationship
Health of a person
Divisibility
A. Movement